package com.itheima.ai.config;

import com.itheima.ai.constants.SystemConstants;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;


@Configuration
public class CommonConfiguration {

    @Bean
    public ChatMemory chatMemory(){
        return MessageWindowChatMemory.builder().build();
    }
//
    @Bean
    public ChatClient chatclient(OpenAiChatModel openAiChatModel,ChatMemory chatMemory){
        return ChatClient
                .builder(openAiChatModel)
                .defaultSystem("你是一个热心、可爱的智能助手，你的名字叫意意，你是一头小猪")
                .defaultAdvisors(
                        new SimpleLoggerAdvisor(),//这个是日志重点
                        MessageChatMemoryAdvisor.builder(chatMemory).build()
                )
                .build();

    }

//    @Bean
//    public ChatClient getchatclient(OpenAiChatModel openAiChatModel,ChatMemory chatMemory){
//        return ChatClient
//                .builder(openAiChatModel)
//                .defaultSystem(SystemConstants.GAME_SYSTEM_PROMPT)
//                .defaultAdvisors(
//                        new SimpleLoggerAdvisor(),//这个是日志重点
//                        MessageChatMemoryAdvisor.builder(chatMemory).build()
//                )
//                .build();
//
//    }
}
